package com.yanfan.ccapi.service.impl;

import com.yanfan.ccapi.service.ICcapiCustomMappingService;
import com.yanfan.ccapicode.dao.CustomMappingRepository;
import com.yanfan.ccapicode.dao.entity.CustomMappingDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 自定义映射模板Service业务层处理
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@Service
public class CcapiCustomMappingServiceImpl implements ICcapiCustomMappingService {
    @Autowired
    private CustomMappingRepository ccapiCustomMappingMapper;

    /**
     * 查询自定义映射模板
     *
     * @param id 自定义映射模板主键
     * @return 自定义映射模板
     */
    @Override
    public CustomMappingDO selectCcapiCustomMappingById(Long id) {
        return ccapiCustomMappingMapper.selectCcapiCustomMappingById(id);
    }

    /**
     * 查询自定义映射模板列表
     *
     * @param ccapiCustomMapping 自定义映射模板
     * @return 自定义映射模板
     */
    @Override
    public List<CustomMappingDO> selectCcapiCustomMappingList(CustomMappingDO ccapiCustomMapping) {
        return ccapiCustomMappingMapper.selectCcapiCustomMappingList(ccapiCustomMapping);
    }

    /**
     * 新增自定义映射模板
     *
     * @param ccapiCustomMapping 自定义映射模板
     * @return 结果
     */
    @Override
    public boolean insertCcapiCustomMapping(CustomMappingDO ccapiCustomMapping) {
            return ccapiCustomMappingMapper.insertOrUpdate(ccapiCustomMapping);
    }

    /**
     * 修改自定义映射模板
     *
     * @param ccapiCustomMapping 自定义映射模板
     * @return 结果
     */
    @Override
    public boolean updateCcapiCustomMapping(CustomMappingDO ccapiCustomMapping) {
        return ccapiCustomMappingMapper.insertOrUpdate(ccapiCustomMapping);
    }

    /**
     * 批量删除自定义映射模板
     *
     * @param ids 需要删除的自定义映射模板主键
     * @return 结果
     */
    @Override
    public boolean deleteCcapiCustomMappingByIds(Long[] ids) {
        return ccapiCustomMappingMapper.deleteByIds(Arrays.asList(ids));
    }

    /**
     * 删除自定义映射模板信息
     *
     * @param id 自定义映射模板主键
     * @return 结果
     */
    @Override
    public boolean deleteCcapiCustomMappingById(Long id) {
        return ccapiCustomMappingMapper.deleteById(id);
    }
}
